home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / ole2book.zip / CHAP10.ZIP / CHAP10 / SCHMOO / SCHMOO.H < prev    next >
C/C++ Source or Header  |  1993-06-23  |  8KB  |  282 lines

  1. /*
  2.  * SCHMOO.H
  3.  * Chapter 10 Modification
  4.  *
  5.  * Single include file that pulls in everything needed for other source
  6.  * files in the Schmoo application.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _SCHMOO_H_
  19. #define _SCHMOO_H_
  20.  
  21. #include <windows.h>
  22. #include <memory.h>
  23. #include <ole2.h>   //Required for storage use
  24. #include <ole2ver.h>
  25. //CHAPTER10MOD
  26. #include <ole2ui.h>
  27. //End CHAPTER10MOD
  28. #include <bookguid.h>
  29.  
  30. //These include files reference DLLs that don't have extern "C" already
  31. extern "C"
  32.     {
  33.     #include <commdlg.h>
  34.     }
  35.  
  36. #include <classlib.h>
  37. #include "resource.h"
  38.  
  39.  
  40. //Get the editor window information.
  41. #include "polyline.h"
  42.  
  43.  
  44. //SCHMOO.CPP:  Frame object that creates a main window
  45.  
  46. class __far CSchmooFrame : public CFrame
  47.     {
  48.     //CHAPTER10MOD
  49.     friend class CFigureClassFactory;
  50.     friend class CFigure;   //For UI purposes.
  51.     //End CHAPTER10MOD
  52.  
  53.     private:
  54.         HBITMAP         m_hBmpLines[5];     //Menu item bitmaps
  55.         BOOL            m_fInitialized;     //Did OleInitalize work?
  56.  
  57.         //CHAPTER10MOD
  58.         BOOL            m_fEmbedding;       //-Embedding on command line?
  59.         DWORD           m_dwRegCO;          //From CoRegisterClassObject
  60.         LPCLASSFACTORY  m_pIClassFactory;
  61.         //End CHAPTER10MOD
  62.  
  63.     protected:
  64.         //Overridable for creating a CClient for this frame
  65.         virtual LPCClient CreateCClient(void);
  66.  
  67.         virtual BOOL      FRegisterAllClasses(void);
  68.         virtual BOOL      FPreShowInit(void);
  69.  
  70.         //CHAPTER10MOD
  71.         virtual void      ParseCommandLine(void);
  72.         //End CHAPTER10MOD
  73.  
  74.         virtual UINT      CreateGizmos(void);
  75.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  76.         virtual void      OnDocumentDataChange(LPCDocument);
  77.         virtual void      OnDocumentActivate(LPCDocument);
  78.  
  79.         //New for this class
  80.         virtual void      CreateLineMenu(void);
  81.  
  82.     public:
  83.         CSchmooFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  84.         virtual ~CSchmooFrame(void);
  85.  
  86.         //Overrides
  87.         virtual BOOL      FInit(LPFRAMEINIT);
  88.         virtual void      UpdateMenus(HMENU, UINT);
  89.         virtual void      UpdateGizmos(void);
  90.  
  91.         //New for this class
  92.         virtual void      CheckLineSelection(UINT);
  93.  
  94.         //CHAPTER10MOD
  95.         virtual void      UpdateEmbeddingUI(BOOL, LPCDocument, LPCSTR, LPCSTR);
  96.         //End CHAPTER10MOD
  97.     };
  98.  
  99.  
  100. typedef CSchmooFrame FAR * LPCSchmooFrame;
  101.  
  102.  
  103.  
  104.  
  105.  
  106. //CLIENT.CPP
  107.  
  108. /*
  109.  * The only reason we have a derived class here is to override
  110.  * CreateCDocument so we can create our own type as well as
  111.  * overriding NewDocument to perform one other piece of work once the
  112.  * document's been created.
  113.  */
  114.  
  115. class __far CSchmooClient : public CClient
  116.     {
  117.     protected:
  118.         //Overridable for creating a new CDocument
  119.         virtual LPCDocument CreateCDocument();
  120.  
  121.     public:
  122.         CSchmooClient(HINSTANCE);
  123.         virtual ~CSchmooClient(void);
  124.  
  125.         virtual LPCDocument NewDocument(BOOL, LPCDocumentAdviseSink);
  126.     };
  127.  
  128.  
  129. typedef CSchmooClient FAR * LPCSchmooClient;
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. //DOCUMENT.CPP
  137.  
  138. //Constant ID for the window polyline that lives in a document window
  139. #define ID_POLYLINE         10
  140.  
  141. class __far CSchmooDoc : public CDocument
  142.     {
  143.     friend class CPolylineAdviseSink;
  144.  
  145.     //These need access to FQueryPasteFromData, FPasteFromData
  146.     friend class CDropTarget;
  147.     friend class CDropSource;
  148.  
  149.     //CHAPTER10MOD
  150.     friend class CFigureClassFactory;
  151.     friend class CFigure;
  152.     //End CHAPTER10MOD
  153.  
  154.     protected:
  155.         UINT            m_uPrevSize;        //Last WM_SIZE wParam
  156.         LONG            m_lVer;             //Loaded Polyline version
  157.  
  158.         LPCPolyline             m_pPL;      //Polyline Editor window in us.
  159.         LPCPolylineAdviseSink   m_pPLAdv;   //Advises from Polyline
  160.  
  161.         class CDropTarget FAR  *m_pDropTarget;  //Registered target.
  162.  
  163.         BOOL            m_fDragSource;      //Drag-drop source==target
  164.  
  165.         //CHAPTER10MOD
  166.         UINT            m_cfEmbedSource;        //Compound Doc format.
  167.         UINT            m_cfObjectDescriptor;   //Compound Doc format.
  168.  
  169.         class CFigure FAR      *m_pFigure;      //The object in us.
  170.         //End CHAPTER10MOD
  171.  
  172.     protected:
  173.         virtual BOOL    FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  174.         void            DropSelectTargetWindow(void);
  175.  
  176.     public:
  177.         CSchmooDoc(HINSTANCE);
  178.         virtual ~CSchmooDoc(void);
  179.  
  180.         virtual BOOL     FInit(LPDOCUMENTINIT);
  181.         virtual void     Clear();
  182.  
  183.         //CHAPTER10MOD
  184.         virtual BOOL     FDirtySet(BOOL);
  185.         virtual BOOL     FDirtyGet(void);
  186.         //End CHAPTER10MOD
  187.  
  188.         virtual UINT     ULoad(BOOL, LPSTR);
  189.         virtual UINT     USave(UINT, LPSTR);
  190.  
  191.         virtual void     Undo(void);
  192.         virtual BOOL     FClip(HWND, BOOL);
  193.         virtual HGLOBAL  RenderFormat(UINT);
  194.         //CHAPTER10MOD
  195.         virtual BOOL     FRenderMedium(UINT, LPSTGMEDIUM);
  196.         //End CHAPTER10MOD
  197.         virtual BOOL     FQueryPaste(void);
  198.         virtual BOOL     FPaste(HWND);
  199.  
  200.         //CHAPTER10MOD
  201.         //These were protected.  Now for IOleObject, should be public.
  202.         virtual BOOL    FQueryPasteFromData(LPDATAOBJECT);
  203.         virtual BOOL    FPasteFromData(LPDATAOBJECT);
  204.         LPDATAOBJECT    TransferObjectCreate(BOOL);
  205.         //End CHAPTER10MOD
  206.  
  207.         virtual COLORREF ColorSet(UINT, COLORREF);
  208.         virtual COLORREF ColorGet(UINT);
  209.  
  210.         virtual UINT     LineStyleSet(UINT);
  211.         virtual UINT     LineStyleGet();
  212.     };
  213.  
  214. typedef CSchmooDoc FAR * LPCSchmooDoc;
  215.  
  216.  
  217. //These color indices wrap the polyline definitions
  218. #define DOCCOLOR_BACKGROUND             POLYLINECOLOR_BACKGROUND
  219. #define DOCCOLOR_LINE                   POLYLINECOLOR_LINE
  220.  
  221.  
  222.  
  223. //Drag-drop interfaces we need in the document
  224. class __far CDropTarget : public IDropTarget
  225.     {
  226.     protected:
  227.         ULONG               m_cRef;      //Interface reference count.
  228.         LPCSchmooDoc        m_pDoc;      //Back pointer to the document
  229.  
  230.         LPDATAOBJECT        m_pIDataObject;  //Data object from DragEnter
  231.  
  232.     public:
  233.         CDropTarget(LPCSchmooDoc);
  234.         ~CDropTarget(void);
  235.  
  236.         //IDropTarget interface members
  237.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  238.         STDMETHODIMP_(ULONG) AddRef(void);
  239.         STDMETHODIMP_(ULONG) Release(void);
  240.  
  241.         STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  242.         STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
  243.         STDMETHODIMP DragLeave(void);
  244.         STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  245.     };
  246.  
  247.  
  248. typedef CDropTarget FAR * LPCDropTarget;
  249.  
  250.  
  251. class __far CDropSource : public IDropSource
  252.     {
  253.     protected:
  254.         ULONG               m_cRef;      //Interface reference count.
  255.         LPCSchmooDoc        m_pDoc;      //Back pointer to the document
  256.  
  257.     public:
  258.         CDropSource(LPCSchmooDoc);
  259.         ~CDropSource(void);
  260.  
  261.         //IDropSource interface members
  262.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  263.         STDMETHODIMP_(ULONG) AddRef(void);
  264.         STDMETHODIMP_(ULONG) Release(void);
  265.  
  266.         STDMETHODIMP QueryContinueDrag(BOOL, DWORD);
  267.         STDMETHODIMP GiveFeedback(DWORD);
  268.     };
  269.  
  270.  
  271. typedef CDropSource FAR * LPCDropSource;
  272.  
  273.  
  274.  
  275. //CHAPTER10MOD
  276. //Include classes necessary to become an OLE 2.0 server.
  277. #include "schmoole.h"
  278. //End CHAPTER10MOD
  279.  
  280.  
  281. #endif //_SCHMOO_H_
  282.